package icu.d4peng.basic.database.mybatis;

import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.InnerInterceptor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.List;

/**
 * MybatisPlusInnerInterceptorAutoConfiguration:mp拦截器配置
 *
 * @author d4peng <a href="d4peng@qq.com">d4peng@qq.com</a>
 * @since 2023.12.02
 */
@Configuration(proxyBeanMethods = false)
@ConditionalOnBean(InnerInterceptor.class)
@ConditionalOnMissingBean(MybatisPlusInterceptor.class)
public class MybatisPlusInnerInterceptorAutoConfiguration {

	@Bean
	public MybatisPlusInterceptor defaultMybatisPlusInterceptor(List<InnerInterceptor> innerInterceptorList) {
		MybatisPlusInterceptor plusInterceptor = new MybatisPlusInterceptor();
		plusInterceptor.setInterceptors(innerInterceptorList);
		return plusInterceptor;
	}

}
